Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

app/src/fdroid/java/com/geeksville/mesh/util/MapUtils.kt ui_message_list (be3f882f) Text, 2.73 KB

T8b949e/*
* Copyright (c) 2025 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

Tff7b72package T7ee787com.geeksville.mesh.util

Tff7b72import T7ee787org.osmdroid.util.BoundingBox
Tff7b72import T7ee787org.osmdroid.util.GeoPoint
Tff7b72import T7ee787kotlin.math.log2
Tff7b72import T7ee787kotlin.math.pow

Tff7b72private Tff7b72const Tff7b72val Te6edf3DEGREES_IN_CIRCLE Tff7b72= T79c0ff3T79c0ff6T79c0ff0.0
Tff7b72private Tff7b72const Tff7b72val Te6edf3METERS_PER_DEGREE_LATITUDE Tff7b72= T79c0ff1T79c0ff1T79c0ff1T79c0ff3T79c0ff2T79c0ff0.0
Tff7b72private Tff7b72const Tff7b72val Te6edf3ZOOM_ADJUSTMENT_FACTOR Tff7b72= T79c0ff0.8

T8b949e/**
* Calculates the zoom level required to fit the entire [BoundingBox] inside the map view.
*
* @return The zoom level as a Double value.
*/
Tff7b72fun Te6edf3BoundingBoxTb4b4b4.Td2a8ffrequiredZoomLevelTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Double Tb4b4b4{
Tff7b72val Te6edf3topLeft Tff7b72= Te6edf3GeoPointTb4b4b4(Tff7b72thisTb4b4b4.Te6edf3latNorthTb4b4b4, Tff7b72thisTb4b4b4.Te6edf3lonWestTb4b4b4)
Tff7b72val Te6edf3bottomRight Tff7b72= Te6edf3GeoPointTb4b4b4(Tff7b72thisTb4b4b4.Te6edf3latSouthTb4b4b4, Tff7b72thisTb4b4b4.Te6edf3lonEastTb4b4b4)
Tff7b72val Te6edf3latLonWidth Tff7b72= Te6edf3topLeftTb4b4b4.Te6edf3distanceToAsDoubleTb4b4b4(Te6edf3GeoPointTb4b4b4(Te6edf3topLeftTb4b4b4.Te6edf3latitudeTb4b4b4, Te6edf3bottomRightTb4b4b4.Te6edf3longitudeTb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3latLonHeight Tff7b72= Te6edf3topLeftTb4b4b4.Te6edf3distanceToAsDoubleTb4b4b4(Te6edf3GeoPointTb4b4b4(Te6edf3bottomRightTb4b4b4.Te6edf3latitudeTb4b4b4, Te6edf3topLeftTb4b4b4.Te6edf3longitudeTb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3requiredLatZoom Tff7b72= Te6edf3log2Tb4b4b4(Te6edf3DEGREES_IN_CIRCLE Tff7b72/ Tb4b4b4(Te6edf3latLonHeight Tff7b72/ Te6edf3METERS_PER_DEGREE_LATITUDETb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3requiredLonZoom Tff7b72= Te6edf3log2Tb4b4b4(Te6edf3DEGREES_IN_CIRCLE Tff7b72/ Tb4b4b4(Te6edf3latLonWidth Tff7b72/ Te6edf3METERS_PER_DEGREE_LATITUDETb4b4b4)Tb4b4b4)
Tff7b72return Te6edf3maxOfTb4b4b4(Te6edf3requiredLatZoomTb4b4b4, Te6edf3requiredLonZoomTb4b4b4) Tff7b72* Te6edf3ZOOM_ADJUSTMENT_FACTOR
Tb4b4b4}

T8b949e/**
* Creates a new bounding box with adjusted dimensions based on the provided [zoomFactor].
*
* @return A new [BoundingBox] with added [zoomFactor]. Example:
* ```
* // Setting the zoom level directly using setZoom()
* map.setZoom(14.0)
* val boundingBoxZoom14 = map.boundingBox
*
* // Using zoomIn() results the equivalent BoundingBox with setZoom(15.0)
* val boundingBoxZoom15 = boundingBoxZoom14.zoomIn(1.0)
* ```
*/
Tff7b72fun Te6edf3BoundingBoxTb4b4b4.Td2a8ffzoomInTb4b4b4(Te6edf3zoomFactorTb4b4b4: Tffa657DoubleTb4b4b4)Tb4b4b4: Te6edf3BoundingBox Tb4b4b4{
Tff7b72val Te6edf3center Tff7b72= Te6edf3GeoPointTb4b4b4(Tb4b4b4(Te6edf3latNorth Tff7b72+ Te6edf3latSouthTb4b4b4) Tff7b72/ T79c0ff2Tb4b4b4, Tb4b4b4(Te6edf3lonWest Tff7b72+ Te6edf3lonEastTb4b4b4) Tff7b72/ T79c0ff2Tb4b4b4)
Tff7b72val Te6edf3latDiff Tff7b72= Te6edf3latNorth Tff7b72- Te6edf3latSouth
Tff7b72val Te6edf3lonDiff Tff7b72= Te6edf3lonEast Tff7b72- Te6edf3lonWest

Tff7b72val Te6edf3newLatDiff Tff7b72= Te6edf3latDiff Tff7b72/ Tb4b4b4(T79c0ff2.0Tb4b4b4.Te6edf3powTb4b4b4(Te6edf3zoomFactorTb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3newLonDiff Tff7b72= Te6edf3lonDiff Tff7b72/ Tb4b4b4(T79c0ff2.0Tb4b4b4.Te6edf3powTb4b4b4(Te6edf3zoomFactorTb4b4b4)Tb4b4b4)

Tff7b72return Te6edf3BoundingBoxTb4b4b4(
Te6edf3centerTb4b4b4.Te6edf3latitude Tff7b72+ Te6edf3newLatDiff Tff7b72/ T79c0ff2Tb4b4b4,
Te6edf3centerTb4b4b4.Te6edf3longitude Tff7b72+ Te6edf3newLonDiff Tff7b72/ T79c0ff2Tb4b4b4,
Te6edf3centerTb4b4b4.Te6edf3latitude Tff7b72- Te6edf3newLatDiff Tff7b72/ T79c0ff2Tb4b4b4,
Te6edf3centerTb4b4b4.Te6edf3longitude Tff7b72- Te6edf3newLonDiff Tff7b72/ T79c0ff2Tb4b4b4,
Tb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s